#include "testApp.h"

//--------------------------------------------------------------
void testApp::setup(){
    
    ofBackground(0);
    
    for(int i = 0; i < NUM_POS; i++){
        xPos[i] = ofRandomWidth();
        yPos[i] = ofRandomHeight();
        
        pos[i].set(ofRandomWidth(), ofRandomHeight());
    }
    
    for(int x = 0; x < GRID_W; x++){
        for(int y = 0; y < GRID_H; y++){
            if(ofRandom(2) > 1){
                grid[x][y] = true;
            } else {
                grid[x][y] = false;
            }
        }
    }
    
}

//--------------------------------------------------------------
void testApp::update(){
    
}

//--------------------------------------------------------------
void testApp::draw(){
    
    for(int i = 0; i < NUM_POS; i++){
        ofSetColor(0, 0, 255);
        ofRect(xPos[i], yPos[i], 10, 10);
        
        ofSetColor(255, 0, 0);
        ofCircle(pos[i], 13);
    }
    
    for(int x = 0; x < GRID_W; x++){
        for(int y = 0; y < GRID_H; y++){
            if(grid[x][y]){
                ofSetColor(255);
            } else{
                ofSetColor(100);
            }
            
            ofRect(x * 10, y * 10, 10, 10);
        }
    }
    
    for(int i = 0; i < newCircs.size(); i++){
        ofSetColor(0, 255, 0);
        ofCircle(newCircs[i], 10);
    }
}

//--------------------------------------------------------------
void testApp::keyPressed(int key){
    newCircs.pop_back();
}

//--------------------------------------------------------------
void testApp::keyReleased(int key){
    
}

//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
    
}

//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
    
}

//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
    newCircs.push_back(ofPoint(ofRandomWidth(), ofRandomHeight()));
}

//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
    
}

//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
    
}

//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
    
}

//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){ 
    
}